import time

from selenium.webdriver.common.by import By

from page_object.pages.BasePage import BasePage



class ReleasePage(BasePage):
    _et_content = (By.ID, 'et_content')
    _dynamic_redpackage = (By.ID, 'dynamic_redpackage')
    _ivCenter = (By.ID, 'ivCenter')  #点击录音按钮
    _ivSoundCommit = (By.ID, 'ivSoundCommit')   #确认录音按钮
    _iv_right = (By.ID, 'iv_right') #发布按钮

    def release_news(self, text):
        '''
        输入发布内容
        :param text:
        :return:
        '''
        self.find(self._et_content).send_keys(text)
        # todo:看看发红包怎么写
        return self

    def goto_send_red_page(self):
        '''
        去发红包页面
        :return:
        '''
        self.find(self._dynamic_redpackage).click()
        from page_object.pages.ReleaseNewsRedPage import ReleaseNewsRedPage
        return ReleaseNewsRedPage()

    def sound_recording(self):
        '''
        录音
        :return:
        '''
        self.find_by_xpath('录音').click()
        self.find(self._ivCenter).click()
        time.sleep(5)
        self.find(self._ivCenter).click()
        self.find(self._ivSoundCommit).click()
        return self

    def click_send(self):
        '''
        点击发送按钮
        :return:
        '''
        self.find(self._iv_right).click()
        self.find_by_xpath('知道了').click()
        from page_object.pages.CirclePage import CirclePage
        return CirclePage()



